from django.shortcuts import render, redirect
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse

# Create your views here.

def login(request):
    return render(request, "login.html")


def get_login_info(request):
    name = request.POST.get("username")
    password = request.POST.get("password")
    if name == "zyd" and password == "123":

        dict1 = {"name": name, "password": password}
        # return redirect("/hello/", )  # 去找路由---视图函数-----渲染出html文件(重定向)
        return HttpResponseRedirect(reverse("hello world"))  # 通过别名找到路由

        # return render(request, "login_form.html", context=dict1)
    else:
        return render(request, "login.html", context={"is_login": 1, "username": name, "password": password})


def hello(request):
    return render(request, "hello.html")
